<?php
/**
 * Created by PhpStorm.
 * User: chenyuz
 * Date: 2019/3/5
 * Time: 15:41
 */
namespace app\ops\controller;

use app\service\PromoService;
use think\Db;

class Promo extends Base{
    public function index() {
        $list = Db::name("promo_code")->order("status desc, id desc")->paginate(10);
        $this->assign("list", $list);
        return $this->fetch();
    }

    function add(){

        $num = request()->param('num', 1);

        PromoService::createPromoCode($num);

        return success([]);
    }

    function setstatus(){
        $id = request()->param('id', 0);

        \db('promo_code')->where(['id'=> $id])->update(['status'=> 0]);

        return success([]);
    }
}